Repository navigation
Keep the restricted action RHP on the stack when opening Subscription - #101853
Conversation
Tapping Go to Subscription called closeRHPFlow(), which pops the whole right modal navigator off the root stack and destroys the route that backTo points at. The header back button hid this because goBack(backTo) falls through to a REPLACE that rebuilds the RHP from the URL, but the native swipe-back gesture has no such fallback and revealed whatever was underneath instead. Also guard the auto-dismiss effect on useIsFocused, since the restricted action page now stays mounted under the Subscription page and would otherwise navigate back once the billing issue is resolved there. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
Fixed and pushed as What was failing: The other failing check, Verification
|
|
🤖 Web test steps verification results: The documented flow got as far as submitting a tracked expense to my employer, but the Restricted screen never appeared — this test account owns a workspace with no expired or missing payment requirement, which is the stated precondition. Steps 6–9 depend on that screen, so they could not be observed and are reported as blocked rather than passed. Worth flagging before anyone reads the ❌ rows as a problem with the PR: this fix cannot be validated on Web at all. The only production change is in
To actually verify this fix, someone needs an iOS simulator or device plus an account owning a workspace with an expired required payment. Two things would make that reachable: fill in the |
|
🤖 Android test steps verification results: Recovered from a failed prestart sign-in and completed onboarding by hand, then created and submitted a Self-DM expense via "Submit to my employer". The Restricted screen never appeared, so steps 5–8 could not be exercised: submitting auto-created a brand-new workspace with no expired required payment, which is the documented precondition, so the restriction gate never fired. Android is the right platform to try this on — it loads the changed file, Two things would make this runnable: seed or supply such an account, and fill in the |
|
@MelvinBot when i swipe back on ios, it the RF-1.mov |
…ipe back The button went dead after swiping back because activeRoute was snapshotted at mount. Subscription's own billing fetch toggles the shared isLoadingSubscriptionData flag, which swapped this screen's content for a loading indicator and back again while it sat covered by Subscription. The remount captured getActiveRoute() while Subscription was focused, so backTo pointed at Subscription itself and linkTo's arePathAndBackToEqual guard discarded every later press as a no-op. Read the active route at press time instead, and stop swapping the content out while unfocused so the screen is not needlessly remounted behind the user. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
Good catch — that's a real regression my change introduced, and I've pushed a fix in Root cause:
The fix, two parts:
VerificationI confirmed both are genuine regression guards by reverting each fix and watching the new test fail:
Two tests added: one asserts One caveat worth stating plainly: I could not verify this on a device. Browser control was unavailable in this run, and web doesn't load Please re-test the swipe-back flow on iOS and confirm the button now works on the second press. |
|
No code fix needed — every automated check on the current head ( The one remaining failure is What changed since the last runThe earlier run fixed an Current status on I could not verify the swipe-back behavior in a browser on this run — browser control was unavailable. That doesn't affect this answer, and the gesture in question needs a real iOS device regardless, as the Next step: get a peer review on the PR. |
|
@MelvinBot Merge the main. |
…onSwipeBack Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
Merged
|
|
No code fix needed — every automated check on the current head ( The one remaining failure is When you filed this request the run was only a few minutes old and most jobs were still Final status on
|
| Check | Result |
|---|---|
| TypeScript Checks | ✅ pass |
| ESLint check | ✅ pass |
| Oxfmt check | ✅ pass |
| Jest Unit Tests (jobs 1–8) | ✅ pass |
| Storybook tests | ✅ pass |
| Bun tests | ✅ pass |
| Spell check | ✅ pass |
| Knip check | ✅ pass |
| React Compiler Compliance | ✅ pass |
| Check unused styles | ✅ pass |
| Reassure Performance Tests | ✅ pass |
| Remote Build Android (both variants) | ✅ pass |
| Remote Build iOS (both variants) | ✅ pass |
| Verify signed commits / CLA | ✅ pass |
Check independent approval |
❌ needs a human reviewer |
Two things still block this PR that I can't do for you: request a reviewer so Check independent approval can pass, and fill in the Tests / QA Steps sections (both still have // TODO placeholders) before marking it ready for review.
I could not drive NewDot in a browser on this run, so nothing here was verified at runtime — this answer is based on the CI job results alone.
| it('stays put while unfocused so it cannot pop the screen the user is actually on', () => { | ||
| // Given the restricted action screen is still mounted in the RHP but the user has moved on to | ||
| // the Subscription page, where they just resolved the billing issue | ||
| mockIsFocused.mockReturnValue(false); | ||
|
|
||
| // When the fresh server data lifts the restriction | ||
| render(<WorkspaceRestrictedActionPage {...props} />); | ||
|
|
||
| // Then this unfocused screen must not navigate back, which would yank the Subscription page | ||
| // out from under the user mid-payment | ||
| expect(Navigation.goBack).not.toHaveBeenCalled(); | ||
| }); |
There was a problem hiding this comment.
The suite can't tell this guard from a permanent disable.
All five tests render once with a fixed isFocused. None exercises the focus transition, which is the entire point of the change.
Consequence: delete isFocused from the dependency array at WorkspaceRestrictedActionPage.tsx:80 —
}, [policy, isLoadingSubscriptionData, userBillingGracePeriods, ownerBillingGracePeriodEnd, amountOwed, accountID]);
// ^ isFocused removed— and all five tests still pass, while the guard silently degrades into "once unfocused, this screen never auto-dismisses again." A user who resolves billing on Subscription and swipes back would then be stranded on a Restricted screen that no longer applies, with no way out but the back button. That's a worse bug than the one being fixed, and nothing here would catch it.
mockIsFocused is already a mutable jest.fn, so it's three lines:
it('dismisses itself once focus returns after the restriction was lifted elsewhere', () => {
// Given the restricted screen mounted but covered by the Subscription page
mockIsFocused.mockReturnValue(false);
const {rerender} = render(<WorkspaceRestrictedActionPage {...props} />);
expect(Navigation.goBack).not.toHaveBeenCalled();
// When the user resolves billing there and swipes back, re-focusing this screen
mockIsFocused.mockReturnValue(true);
rerender(<WorkspaceRestrictedActionPage {...props} />);
// Then the effect re-runs and dismisses the now-obsolete restriction. Without `isFocused` in the
// effect's dependency array the guard would permanently disable auto-dismiss instead of deferring it.
expect(Navigation.goBack).toHaveBeenCalledTimes(1);
});There was a problem hiding this comment.
Fixed in f13831be5e3 — and you were more right than the comment claims. I added your test verbatim, ran it against the mutation you described, and it still passed.
The reason is one line above: usePolicy was mocked as jest.fn(() => ({id: 'policyID1'})), returning a fresh object on every call. policy is the first entry in that dependency array, so its identity changed on every render and the effect re-ran no matter what else the array contained. isFocused being in there was decorative.
So the mock is now referentially stable:
// Referentially stable, like the real `usePolicy`. Returning a fresh object per render would change a
// dependency of the goBack effect on every render, re-running it no matter what the dependency array says
// and masking a removed `isFocused` dependency.
const mockPolicy = {id: 'policyID1'};
jest.mock('@hooks/usePolicy', () => jest.fn(() => mockPolicy));With that in place I re-ran the mutation: delete isFocused from the dependency array and the new test fails, every other test passes. That's the guard you were asking for.
| jest.mock('@libs/SubscriptionUtils', () => ({ | ||
| shouldRestrictUserBillableActions: () => mockShouldRestrictUserBillableActions(), | ||
| })); |
There was a problem hiding this comment.
shouldRestrictUserBillableActions is mocked with its arguments thrown away. Two problems.
(a) Arguments are never asserted. The real signature takes five (src/libs/SubscriptionUtils.ts:518-524):
function shouldRestrictUserBillableActions(
policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID,
): booleanA refactor that passes accountID where amountOwed belongs, or drops userBillingGracePeriods entirely, passes all five tests. Forward the args and assert them:
expect(mockShouldRestrictUserBillableActions).toHaveBeenCalledWith({id: 'policyID1'}, undefined, undefined, undefined, 1);(b) The module is replaced wholesale. SubscriptionUtils exports ~32 symbols; this factory supplies one. Nothing in today's import graph needs the others, but the moment NotFoundPage, FullScreenLoadingIndicator, or a future child pulls one in, it resolves to undefined and fails at call time with a confusing stack. L20-23 of this same file already uses the safe idiom for @react-navigation/native — apply it here too:
jest.mock('@libs/SubscriptionUtils', () => ({
...jest.requireActual<typeof SubscriptionUtils>('@libs/SubscriptionUtils'),
shouldRestrictUserBillableActions: (...args: Parameters<typeof SubscriptionUtils.shouldRestrictUserBillableActions>) =>
mockShouldRestrictUserBillableActions(...args),
}));There was a problem hiding this comment.
Both fixed in f13831be5e3, applied as written.
const mockShouldRestrictUserBillableActions = jest.fn<boolean, Parameters<typeof SubscriptionUtils.shouldRestrictUserBillableActions>>(() => false);
// Only the restriction gate is replaced. Keeping the rest of the module real means a child that starts
// importing another `SubscriptionUtils` export does not silently resolve it to `undefined`.
jest.mock('@libs/SubscriptionUtils', () => ({
...jest.requireActual<typeof SubscriptionUtils>('@libs/SubscriptionUtils'),
shouldRestrictUserBillableActions: (...args: Parameters<typeof SubscriptionUtils.shouldRestrictUserBillableActions>) => mockShouldRestrictUserBillableActions(...args),
}));The assertion is toHaveBeenCalledWith(mockPolicy, undefined, undefined, undefined, 1) — mockPolicy rather than an inline literal, since the usePolicy mock now has to be referentially stable for the dependency-array test to mean anything (see the thread on L114).
Mutation-checked: swapping amountOwed for accountID at the call site in the page fails this test and nothing else.
|
|
||
| // `isLoadingSubscriptionData` gates both the goBack effect and the loading indicator, so the tests drive it. | ||
| const mockIsLoadingSubscriptionData = jest.fn<boolean | undefined, []>(() => false); | ||
| jest.mock('@hooks/useOnyx', () => (key: string) => [key === 'isLoadingSubscriptionData' ? mockIsLoadingSubscriptionData() : undefined]); |
There was a problem hiding this comment.
Magic Onyx key string.
'isLoadingSubscriptionData' is the raw value of ONYXKEYS.IS_LOADING_SUBSCRIPTION_DATA (src/ONYXKEYS.ts:487). If that key is renamed, the mock silently returns undefined for everything and the failure surfaces as an unrelated-looking assertion failure in the goBack tests rather than pointing at the key. Reference the constant — jest.requireActual it inside the factory to dodge the hoisting restriction — or at minimum leave a comment pinning the two together.
Separately: the mock returns a 1-tuple, but the real useOnyx returns [value, result]. Fine today, but it means this suite can't catch a migration to result.status, and it bypasses the hook's real signature entirely so a return-shape change goes unnoticed.
There was a problem hiding this comment.
Both fixed in f13831be5e3. jest.requireActual inside the factory, as suggested, and the real two-element tuple:
jest.mock('@hooks/useOnyx', () => {
const {default: actualOnyxKeys} = jest.requireActual<{default: typeof ONYXKEYS}>('@src/ONYXKEYS');
// Mirrors the real `[value, result]` tuple so a migration to `result.status` does not read `undefined`.
return (key: string) => [key === actualOnyxKeys.IS_LOADING_SUBSCRIPTION_DATA ? mockIsLoadingSubscriptionData() : undefined, {status: 'loaded'}];
});Renaming IS_LOADING_SUBSCRIPTION_DATA now breaks the mock at the constant rather than silently returning undefined from three different keys.
|
|
||
| jest.mock('@hooks/useCurrentUserPersonalDetails', () => jest.fn(() => ({accountID: 1, email: 'owner@example.com'}))); | ||
| jest.mock('@hooks/usePolicy', () => jest.fn(() => ({id: 'policyID1'}))); | ||
| jest.mock('@hooks/useNetwork', () => jest.fn(() => ({isOffline: false}))); |
There was a problem hiding this comment.
The offline branch is unreachable in every test.
useNetwork is hard-mocked to {isOffline: false}, so !isOffline in the loading condition (L88 of the page) is never false in any of the five tests. Given this PR is specifically about a screen that now survives connectivity changes instead of being unmounted, that's a notable blind spot — and it's the same hook carrying the unguarded onReconnect I flagged on WorkspaceRestrictedActionPage.tsx:39.
Make it drivable so the offline branch and the reconnect path can both be covered:
const mockIsOffline = jest.fn(() => false);
const mockOnReconnect = jest.fn();
jest.mock('@hooks/useNetwork', () =>
jest.fn(({onReconnect}: {onReconnect?: () => void} = {}) => {
mockOnReconnect.mockImplementation(() => onReconnect?.());
return {isOffline: mockIsOffline()};
}),
);That gives you two more tests worth having: "skips the loading indicator while offline" and "does not refetch on reconnect while unfocused."
There was a problem hiding this comment.
Fixed in f13831be5e3, including the production side. Both tests you named now exist.
useNetwork is drivable — I dropped the mockOnReconnect half of your snippet, because chasing down the unguarded refetch showed the callback shouldn't exist at all:
// Drivable so the offline branch of the loading condition and the reconnect refetch are both reachable.
const mockIsOffline = jest.fn(() => false);
jest.mock('@hooks/useNetwork', () => jest.fn(() => ({isOffline: mockIsOffline()})));On the unguarded onReconnect. Note your WorkspaceRestrictedActionPage.tsx:39 comment didn't land on the PR — only these four on the test file were submitted, so I worked from the reference here. Guarding the callback alone would have fixed nothing: the effect below it has [isOffline] in its dependency array, so isOffline flipping back to false re-runs it and fires the very same openSubscriptionPage request. onReconnect was a duplicate of that path, not a separate one — every reconnect issued two OpenSubscriptionPage reads. So the callback is gone and the focus guard lives on the effect that was already doing the work:
const {isOffline} = useNetwork();
useEffect(() => {
if (isOffline || !isFocused) {
return;
}
openSubscriptionPage(gracePeriodsRef.current);
}, [isOffline, isFocused]);That matters here specifically because this PR is what keeps the screen mounted underneath Subscription. openSubscriptionPage sets isLoadingSubscriptionData to true and optimistically clears the whole grace-period collection — so the covered screen firing it was reaching into the focused page's loading state.
Adding isFocused to the dependencies also covers the case it creates: a reconnect deferred while unfocused runs when the user swipes back, so the screen decides whether to stay up using server data rather than whatever was cached before they left.
Four tests, all mutation-checked (reverting the guard fails the last two and nothing else):
skips the loading indicator while offlinedoes not fetch fresh billing data while offlinedoes not refetch on reconnect while unfocusedfetches fresh billing data once focus returns
|
@MelvinBot check the new comments. |
- Add a focus-transition test so removing `isFocused` from the goBack effect deps fails the suite instead of silently disabling auto-dismiss forever. - Make the `usePolicy` mock referentially stable; a fresh object per render re-ran the effect regardless of its dependency array and masked that removal. - Forward and assert the five `shouldRestrictUserBillableActions` arguments. - Spread `jest.requireActual` into the `SubscriptionUtils` mock instead of replacing the module with a single export. - Read the Onyx key from the real `ONYXKEYS` and return the real `[value, result]` tuple in the `useOnyx` mock. - Make `useNetwork` drivable and cover the offline branch. - Guard the billing refetch on focus so the covered screen no longer duplicates the Subscription page's fetch on reconnect, and drop the redundant `onReconnect` callback that fired the same request a second time. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
All four review comments addressed in Your first comment understated the problem. I added your focus-transition test verbatim, ran the mutation you described — delete One change reached the production file. You referenced a comment on The other three were applied as written: forwarded and asserted arguments, Five new tests, from 5 to 10. Every guard is mutation-checked — I reverted each production guard and confirmed the intended test fails and no other. Verification
Mutation results, one at a time against the final test file:
The |
|
No new comments. Everything currently on this PR is already addressed — your four inline review comments were handled in Full state of your requests:
If you left more feedback as a pending review, it hasn't been submitted — the API shows nothing past your One thing worth your attention: the MelvinBot CI Fix Loop Detected warning above is a false positive. It counts consecutive MelvinBot commits, not CI-fix attempts — of the five on this branch, exactly one ( CI is green on What's still outstanding (neither is mine to do)
|
|
@MelvinBot refill the PR author checklist with verified one Verified PR checklistExplanation of ChangeOn the native Restricted screen, tapping Go to Subscription called The header back button masked the problem. It calls The fix: drop the Companion change: with the RHP left open, This bug was not introduced by Gate "Submit to my employer" on the workspace billing restriction — that PR changed no navigation code and only made the Restricted screen reachable from one new entry point. The AI TestsRun by Melvin on this branch:
Test changes: Could not run: Fixed Issues$ #101835 TestsPrecondition
Offline testsSam as Tests QA StepsSame as Tests
PR Author Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safari |
|
PR body refilled with your verified checklist. All Three edits to what you supplied, all outside the checklist itself:
One thing to look at before requesting review: the checklist now claims screenshots on all platforms and tests run on all five, but every |
|
@MelvinBot Mark this as ready for review |
|
@marufsharifi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Done — this PR is out of draft and ready for review. Everything automated is green. The only two failing checks are the human gates that can't pass yet:
Thanks for filling in the Unit coverage stands at 13 tests across the two suites, with every guard mutation-checked. |
| Navigation.closeRHPFlow(); | ||
| Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(activeRoute)); | ||
| }, [activeRoute]); | ||
| // Read the active route at press time rather than snapshotting it at mount. This screen stays |
There was a problem hiding this comment.
❌ CLEAN-REACT-PATTERNS-0 (docs)
React Compiler is enabled in this codebase and automatically memoizes closures based on their captured variables. The PR's own compliance table reports this component passes the React Compiler check, so the manual useCallback wrapper here is redundant. Now that the dependency array is [] and the active route is read at press time, the closure captures nothing, making the wrapper pure overhead.
Remove the useCallback and use a plain function so the compiler can handle memoization:
const goToSubscription = () => {
// Read the active route at press time ...
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()));
};You can then drop the useCallback import from the react import statement.
Reviewed at: f13831b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Agreed, fixed in d4f41e4. goToSubscription is a plain function now and the useCallback import is gone from the react import.
The suggestion is right about why: once the active route moved to press time, the closure captures nothing and the dependency array is empty, so the wrapper was doing nothing the compiler doesn't already do.
Verified per the rule's prerequisite before applying — react-compiler-compliance-check check on this file reports no failures, so the file does compile and the rule applies.
| // Read the active route at press time rather than snapshotting it at mount. This screen stays | ||
| // mounted underneath the Subscription page, so a mount-time snapshot can be taken while | ||
| // Subscription is the focused route and would make `backTo` point at Subscription itself — | ||
| // `linkTo` then drops the navigation as a no-op and the button stops working after a swipe back. |
There was a problem hiding this comment.
❌ CONSISTENCY-15 (docs)
Comments should read as plain, natural sentences without stylistic tics like em dashes. This comment uses an em dash (—) to join two clauses.
Split it into two plain sentences:
// ...would make `backTo` point at Subscription itself.
// `linkTo` then drops the navigation as a no-op and the button stops working after a swipe back.Reviewed at: f13831b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Fixed in d4f41e4, split into two plain sentences:
// Subscription is the focused route, which would make `backTo` point at Subscription itself.
// `linkTo` then drops the navigation as a no-op and the button stops working after a swipe back.| // | ||
| // A `useNetwork({onReconnect})` callback is deliberately not used here. `isOffline` flipping back to | ||
| // false already re-runs this effect on reconnect, so the callback only fired the same request a second | ||
| // time — and it fired outside this focus guard. |
There was a problem hiding this comment.
❌ CONSISTENCY-15 (docs)
Comments should read as plain, natural sentences without stylistic tics like em dashes. This comment uses an em dash (—) to join two clauses.
Rewrite it as two plain sentences:
// false already re-runs this effect on reconnect, so the callback only fired the same request a second
// time. It also fired outside this focus guard.Reviewed at: f13831b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Fixed in d4f41e4, applied as suggested:
// false already re-runs this effect on reconnect, so the callback only fired the same request a second
// time. It also fired outside this focus guard.While in here I swept the rest of the diff for the same rule and found two more the review missed, both in tests/unit/pages/RestrictedAction/WorkspaceOwnerRestrictedActionTest.tsx and both fixed in the same commit:
- L162 — an em dash pair:
// When the user swipes back — re-focusing this screen — and taps… - L167 — a semicolon joining two clauses:
…making backTo self-referential; \linkTo` discards such a navigation…`
I left the semicolon on L12 of that file alone, since it's a pre-existing line this PR doesn't touch.
|
@MelvinBot check the latest comments. |
…ents - CLEAN-REACT-PATTERNS-0: remove the `useCallback` around `goToSubscription` and its `react` import. The dependency array is now empty and the closure captures nothing, so React Compiler handles the memoization. - CONSISTENCY-15: replace em dashes with plain sentences in the two flagged comments, plus a third em dash and a clause-joining semicolon in WorkspaceOwnerRestrictedActionTest.tsx that the review did not flag. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
Three new comments since my last reply, all from the AI code reviewer at 11:42. All three were valid and are fixed in
The Two more the reviewer missed. I swept the rest of the diff for Verification
Before applying the ESLint OOM'd the Node heap when given all four files in one invocation, so I ran it in smaller batches. Same rules, same result. CI is re-running on |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-09-24.at.5.38.50.PM.movAndroid: mWeb ChromeiOS: HybridAppScreen.Recording.2026-09-24.at.5.23.14.PM.moviOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-09-24.at.5.53.33.PM.mov |
|
🚧 MariaHCD has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/MariaHCD in version: 9.4.94-0 🚀
|
|
No help site changes are required for this PR, so I did not create a docs PR. This PR fixes internal navigation only. Now, when you swipe back from Subscription after tapping Go to Subscription, you return to the Restricted screen. Labels, settings, and the steps you follow stay the same. What I checked
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.94-0 🚀
Bundle Size Analysis (Sentry): |










Explanation of Change
On the native Restricted screen, tapping Go to Subscription called
Navigation.closeRHPFlow()before navigating. Because that screen is the only route in its RHP,closeRHPFlowpops the wholeRIGHT_MODAL_NAVIGATORoff the root stack — destroying the very route that thebackToparam points at. Subscription then pushed into the Settings split navigator insideTAB_NAVIGATOR, leaving the root stack as[Tab → Self-DM]→[Tab → Subscription].The header back button masked the problem. It calls
Navigation.goBack(backTo), which findsindexOfBackToRoute === -1ingoUpand falls into the REPLACE branch that re-creates the Restricted RHP from the URL. The iOS native swipe-back gesture never runs that code — react-navigation just pops the top root route, revealing whatever was underneath (the Self-DM).backTois an app-level convention with no gesture equivalent, so the two paths could never agree while the target route was destroyed.The fix: drop the
closeRHPFlow()call and letNavigation.navigaterun on its own.linkToalready converts a tab-navigator target into a PUSH when the top root route isn't a tab navigator — RHP is the case that branch was written for. The root stack becomes[Tab → Self-DM]→[RHP → Restricted]→[Tab → Subscription], so the gesture andgoBack(backTo)(nowdistanceToPop === 1→popTo) both land on the Restricted screen.Companion changes: with the RHP left open,
WorkspaceRestrictedActionPagestays mounted underneath the Subscription page. Two effects there assumed it would have been unmounted:Navigation.goBack(), yanking Subscription out from under them mid-payment. It is now gated onuseIsFocused().openSubscriptionPagesets the sharedisLoadingSubscriptionDataflag and optimistically clears the whole grace-period collection, reaching into the focused page's state. It is now gated on the sameisFocused, which also means a refetch deferred while covered runs when the user swipes back. The redundantuseNetwork({onReconnect})callback was removed:isOfflineflipping back tofalsealready re-runs that effect, so every reconnect was issuing twoOpenSubscriptionPagereads.This bug was not introduced by Gate "Submit to my employer" on the workspace billing restriction — that PR changed no navigation code and only made the Restricted screen reachable from one new entry point. The
closeRHPFlow()+navigate()pattern dates to Hide add payments button on mobile, and the same swipe-back behavior reproduces on production via the other ~20ROUTES.RESTRICTED_ACTIONentry points.AI Tests
Run by Melvin on this branch at
f13831be5e3:npm test -- tests/unit/pages/RestrictedAction/npm run typecheck(full, all tsconfigs)npm run spell-changed(cspell, 4 files)npm run fmt(oxfmt, full tree)check, both changed components)Test changes:
WorkspaceOwnerRestrictedActionTest.tsxpreviously assertedcloseRHPFlowwas called, so it was inverted into a regression guard asserting it is not.WorkspaceRestrictedActionPageTest.tsxis new and covers both focus guards.Every guard is mutation-checked — each production guard was reverted one at a time to confirm the intended test fails and no other:
isFocusedfrom thegoBackeffect depsdismisses itself once focus returns…onlydoes not refetch on reconnect while unfocused,fetches fresh billing data once focus returnsamountOwedforaccountIDat the gate call sitedismisses itself when focused…onlyCould not run:
npm run lint-changedand the unqualifiednpm run spell-changedboth abort withgit merge-base failedin this sandbox — nomainmerge base is available. Substituted with directnpx eslintand an explicit cspell file list, which is what those scripts invoke.npm run lintacross the full tree OOM'd the Node heap.npm run prettieris not a script in this version of the repo — formatting is enforced throughnpm run fmt(oxfmt) and ESLint. No iOS simulator was available to Melvin, so the swipe-back gesture was verified by the human co-author rather than by Melvin.Fixed Issues
$ #101835
PROPOSAL: #101835 (comment)
Tests
Precondition
Use an account that owns a workspace with an expired required payment/billing
Go to Subscription.Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari